<?php
/**
 * 发送邮件类
 * 
 * @author OB<yeyq.yfr@yikuaiqu.com>
 */
class EMail
{
    /**
     * 直接发送邮件，发送人地址已经在字典表配置好
     * 
     * @param $msg 邮件内容
     * @return void 无返回
     */
	public static function sendEmail($msg){
		$email = DictionaryHelper::getEmailAccount();
		Yii::app()->mailer->Host = $email['smtp'];
        Yii::app()->mailer->IsSMTP();
        Yii::app()->mailer->SMTPAuth = true;
        Yii::app()->mailer->From = $email['send'][0];         //设置发件地址
        Yii::app()->mailer->AddReplyTo($email['send'][0]);
        Yii::app()->mailer->FromName = $email['name'];   //这里设置发件人姓名
        Yii::app()->mailer->Username = $email['send'][0];    //这里输入发件地址的用户名
        Yii::app()->mailer->Password = $email['send'][1];    //这里输入发件地址的密码
        Yii::app()->mailer->CharSet = 'UTF-8';
        Yii::app()->mailer->Subject = $email['subject']; //设置邮件的主题
        Yii::app()->mailer->Body = $msg;
        foreach ($email['to'] as $toEmail){
        	Yii::app()->mailer->AddAddress($toEmail); //设置收件件地址
        }
        Yii::app()->mailer->Send();
	}
}